Repository navigation
Add route middleware: auth, Throttle, ApiKey, IP filtering, HTTPS, CSRF, Honeypot and signed URLs - #74
Conversation
Secure a route or a group where it is declared, with no firewall rules: - Authenticated@cbsecurity: the user must be logged in - Authorized@cbsecurity: logged in and satisfying the `permissions`, `roles` and `mode` (any|all|none) declared in the route `meta()` - JwtAuth@cbsecurity and BasicAuth@cbsecurity: Authorized, authenticating through the JWT or Basic validators - Guard: the base class for custom middleware Denied requests go through the firewall's invalid access flow, so redirect, override and block actions, module overrides, interception points and logging behave exactly like a firewall rule or annotation. The Security interceptor gains public validateAccess() and processInvalidAccess() methods for this; the annotation path now shares processInvalidAccess() with no behavior change. The route specs run only when the installed ColdBox can run route middleware in execute() and group meta (8.3+); the Guard specs run everywhere. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY
|
CI status
Generated by Claude Code |
…srf, Honeypot and Signed route middleware Adds RateLimiter and UrlSigner models, signedRoute(), signedUrl() and hasValidSignature() mixins, middleware and signedUrls settings, and specs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY
|
CI note on head 113d3fe: Generated by Claude Code |
…ut route middleware - Replace elvis with struct literal operands, which Adobe ColdFusion misparses - Build signedRoute() with loops instead of closures - Skip the ApiKey route specs when the installed ColdBox cannot run route middleware Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY
…operator Adobe ColdFusion ignores a false value on the left of ?:, so a route's honeypotSilent = false fell back to the default. Add getMetaValue() and use it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY
Description
Adds ready-made ColdBox route middleware so a route or a group can be secured where it is declared, without firewall rules. Parameters travel in the route
meta()because a router file loads before modules.Authentication middleware
Authenticated@cbsecurity: logged in (ignores meta)Authorized@cbsecurity: logged in and satisfying routemetapermissions,rolesandmode(any,all,none)JwtAuth@cbsecurity/BasicAuth@cbsecurity: likeAuthorized, through those validatorsGuard: base class for custom middlewareDenied requests go through the firewall's invalid access flow (redirect, override, block, module overrides, interception points, logging).
Securitygains publicvalidateAccess()andprocessInvalidAccess(); the annotation path sharesprocessInvalidAccess()with no behavior change.Abuse protection middleware (new in this update)
They answer denied requests directly with a JSON error and status code. Defaults live in the new
middlewareandsignedUrlsmodule settings, every value can be overridden per route.meta()Throttle@cbsecurity429+Retry-After, named or inline limiters, any CacheBox cache (defaultdefault)throttleApiKey@cbsecurityx-api-keyheader thenapiKeyrequest key (both configurable), keys or a validator serviceapiKeys,apiKeyHeader,apiKeyParamAllowedIPs@cbsecurity/DenyIPs@cbsecurityX-Forwarded-Foronly fromtrustedProxiesallowedIps,denyIpsEnsureHttps@cbsecurity301for GET/HEAD,403for other methodsredirectToHttpsVerifyCsrf@cbsecuritycsrfKeyHoneypot@cbsecurity200or422honeypotField,honeypotSilentSigned@cbsecurityNew models:
RateLimiter@cbsecurity(cache backed fixed window) andUrlSigner@cbsecurity(HMAC-SHA256 over path and query, optional expiration). New mixins:signedRoute(),signedUrl(),hasValidSignature(). A missing IP list or API keys throwscbsecurity.MiddlewareMisconfigured, a missing signing secret throwscbsecurity.SigningSecretMissing.Requirements
metaand middleware insideexecute(): ColdBox 8.3+ (COLDBOX-1459 Route middleware: run it in BaseTestCase.execute() and let group() share meta ColdBox/coldbox-platform#714, merged).registerMiddleware()): COLDBOX-1460 Add Router.registerMiddleware() for named closure, lambda and instance middleware ColdBox/coldbox-platform#719.Type of change
Checklist
cfformatapplied to my filesTesting
BoxLang 1.18, TestBox 7.1, against the companion ColdBox changes: 212 passed, 105 of them in the two middleware specs (
MiddlewareSpec31,SecurityMiddlewareSpec74). The 1 failure and 15 errors are pre-existing and all say "No default datasource" (this sandbox has no MySQL, JWT DB storage specs). Route specs skip themselves through feature detection on ColdBox without 8.3 behavior. I could not run Adobe, Lucee or ColdBox 7 locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY